package com.chuanyang.driverh.mainorder.fragment;


import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.chuanyang.driverh.R;
import com.chuanyang.driverh.base.BaseListAdapter;
import com.chuanyang.driverh.base.BaseListFragment;
import com.chuanyang.driverh.responseresult.DeliverOrderData;

import java.util.HashMap;

public class DeliveryOrderDetailFragment extends BaseListFragment {
    private ViewHolder holder;
    private HashMap params;
    private DeliveryOrderAdapter adapter;

    @Override
    public BaseListAdapter createAdapter() {
        return adapter= new DeliveryOrderAdapter(getActivity());
    }



    @Override
    public void initView(View view) {
        super.initView(view);
        Intent intent=getActivity().getIntent();
        DeliverOrderData deliverOrderData= (DeliverOrderData) intent.getSerializableExtra("data");
        setDataResult(deliverOrderData.getWaybillDetails());
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }


    private  class  DeliveryOrderAdapter extends BaseListAdapter {
        public DeliveryOrderAdapter(Context context) {
            super(context);
        }

        @Override
        public View getZkView(int position, View convertView, ViewGroup parent) {
            if(convertView==null)
            {
                convertView = getInflater().inflate(R.layout.order_item_deliveryorderdetail, parent, false);
                holder = new ViewHolder();
                holder.tv_deliverydetail_itemno= (TextView) convertView.findViewById(R.id.tv_deliverydetail_itemno);
                holder.tv_deliverydetail_noticeno= (TextView) convertView.findViewById(R.id.tv_deliverydetail_noticeno);
                holder.tv_deliverydetail_outbillno= (TextView) convertView.findViewById(R.id.tv_deliverydetail_outbillno);
                holder.tv_deliverydetail_goodname= (TextView) convertView.findViewById(R.id.tv_deliverydetail_goodname);
                holder.tv_deliverydetail_weight= (TextView) convertView.findViewById(R.id.tv_deliverydetail_weight);
                holder.tv_deliverydetail_count= (TextView) convertView.findViewById(R.id.tv_deliverydetail_count);
                holder.tv_deliverydetail_standard= (TextView) convertView.findViewById(R.id.tv_deliverydetail_standard);
                holder.tv_deliverydetail_material= (TextView) convertView.findViewById(R.id.tv_deliverydetail_material);
                convertView.setTag(holder);
            }
            else {
                holder= (ViewHolder) convertView.getTag();
            }
            DeliverOrderData.WaybillDetailsBean  bean= (DeliverOrderData.WaybillDetailsBean) getItem(position);
            if(TextUtils.isEmpty(bean.getOrderDetail().getOrderItemNum()))
            {
                holder.tv_deliverydetail_itemno.setText("");
            }
            else {
                holder.tv_deliverydetail_itemno.setText(bean.getOrderDetail().getOrderItemNum());

            }
            if(TextUtils.isEmpty(bean.getOrderDetail().getNoticeNo()))
            {
                holder.tv_deliverydetail_noticeno.setText("");
            }
            else {
                holder.tv_deliverydetail_noticeno.setText(bean.getOrderDetail().getNoticeNo());

            }
            if(TextUtils.isEmpty(bean.getOrderDetail().getOutDoorNo()))
            {
                holder.tv_deliverydetail_outbillno.setText("");
            }
            else {
                holder.tv_deliverydetail_outbillno.setText(bean.getOrderDetail().getOutDoorNo());

            }
            if(TextUtils.isEmpty(bean.getOrderDetail().getGoodsName()))
            {
                holder.tv_deliverydetail_goodname.setText("");
            }
            else {
                holder.tv_deliverydetail_goodname.setText(bean.getOrderDetail().getGoodsName());

            }
            if(TextUtils.isEmpty("重量："+bean.getOrderDetail().getGoodsWeight()))
            {
                holder.tv_deliverydetail_weight.setText("重量：");
            }
            else {
                holder.tv_deliverydetail_weight.setText("数量："+bean.getOrderDetail().getGoodsWeight());

            }
            if(TextUtils.isEmpty(bean.getOrderDetail().getGoodsNum()))
            {
                holder.tv_deliverydetail_count.setText("数量：");
            }
            else {
                holder.tv_deliverydetail_count.setText("数量："+bean.getOrderDetail().getGoodsNum());

            }
            if(TextUtils.isEmpty(bean.getOrderDetail().getGoodsStandard()))
            {
                holder.tv_deliverydetail_standard.setText("规格：");
            }
            else {
                holder.tv_deliverydetail_standard.setText("规格："+bean.getOrderDetail().getGoodsStandard());

            }
            if(TextUtils.isEmpty(bean.getOrderDetail().getGoodsMaterial()))
            {
                holder.tv_deliverydetail_material.setText("材质：");
            }
            else {
                holder.tv_deliverydetail_material.setText("材质："+bean.getOrderDetail().getGoodsMaterial());

            }
            return convertView;
        }
    }
    class  ViewHolder{
        TextView tv_deliverydetail_itemno;
        TextView tv_deliverydetail_noticeno;
        TextView tv_deliverydetail_outbillno;
        TextView tv_deliverydetail_goodname;
        TextView tv_deliverydetail_weight;
        TextView tv_deliverydetail_count;
        TextView tv_deliverydetail_standard;
        TextView tv_deliverydetail_material;

    }
    @Override
    protected boolean isPullToRefresh() {
        return false;
    }

    @Override
    protected boolean isLoadMore() {
        return false;
    }
}
